package cn.gson.crmdemo.model.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSONArray;

import cn.gson.crmdemo.model.dao.FkjlDao;
import cn.gson.crmdemo.model.mapper.FkjlMapper;
import cn.gson.crmdemo.model.pojo.PaymentPlan;
import cn.gson.crmdemo.model.pojo.PaymentRecord;
import cn.gson.crmdemo.model.pojo.Purchase;
import cn.gson.crmdemo.model.pojo.Supplier;
import cn.gson.crmdemo.model.vo.FkjlVo;

@Service
@Transactional(rollbackFor=Exception.class)
public class FkjlService {
	@Autowired
	FkjlMapper fm;
	@Autowired
	FkjlDao fkdao;
	//查询付款记录
	public JSONArray fkjl(Integer jlFk,String jlDate,Integer fpZt){
		 return fm.selectfkjl(jlFk,jlDate,fpZt);
	}
	//添加付款记录
	public void addfkjl(FkjlVo fo) {
		PaymentRecord rd=new PaymentRecord();
		PaymentPlan pn=new PaymentPlan();
		pn.setFkId(fo.getFkId());
		rd.setPaymentPlan(pn);
		Purchase ps=new Purchase();
		ps.setPurchaseId(fo.getPurchaseId());
		rd.setPurchase(ps);
		Supplier sr=new Supplier();
		sr.setGysId(fo.getGysId());
		rd.setSupplier(sr);
		rd.setJlDate(fo.getJlDate());
		rd.setJlPaid(fo.getJlPaid());
		rd.setJl_Fk(fo.getFkFs());
		rd.setJlPerson(fo.getJlPerson());
		rd.setFp_zt(fo.getFpZt());
		fkdao.save(rd);
	}
	
	
	public void updateState(int a) {
		fm.updateState(a);
	}
	//模糊查询
	public JSONArray selectsj(String rq) {
		return fm.selectsj(rq);
	}
	//付款方式
	public JSONArray selectfs(Integer o) {
		return fm.selectfs(o);
	}
	//是否开票
	public JSONArray selectfp(Integer s) {
		return fm.selectfp(s);
	}
}
